<?php
/**
 * CK 开发框架
 * User: Clake
 * Date: 15/6/18
 * Time: 00:55
 */

namespace CK\Database;


class Product {
    private $db;
    private $pro_name;
    private $pro_h;
    private $query;

    function __construct($data_source,$pro_name) {
        $this->db = $data_source;
        $this->pro_name = $pro_name;
        $this->pro_h = $this->db->init($pro_name);
    }

    function bind($parm_name,&$parm_value,$type,$is_output = false,$is_null = false,$maxlen=-1) {
        $this->db->bind($this->pro_h,$parm_name,$parm_value,$type,$is_output,$is_null,$maxlen);
    }

    function execute(){
        $this->query = $this->db->execute($this->pro_h);
    }

    function get_result() {
        $list = array();
        while($result = $this->db->fetch_array($this->query)) {
            $list[] = $result;
        }
        $this->db->free_stmt($this->pro_h);
        return $list;
    }
}